import unittest
from HTMLTestRunner_cn import HTMLTestRunner
from config.config import CASES_PATH,REPORT_PATH
import time

"""用HTMLTestRunner方式导出报告"""

discover = unittest.defaultTestLoader.discover(CASES_PATH,pattern="test*.py")
report_path = "{}/{}测试报告.html".format(REPORT_PATH,time.strftime("%Y%m%d%H%M%S"))
with open(report_path,'wb') as f:
    runner = HTMLTestRunner(
        stream=f,
        title='测试报告',
        description='用例执行情况'
    )
    runner.run(discover)
